package org.movee.spring.data.hugegraph.convert;

import com.baidu.hugegraph.structure.graph.Edge;
import com.baidu.hugegraph.structure.graph.Vertex;
import org.movee.spring.data.hugegraph.mapping.HugeMappingContext;
import org.movee.spring.data.hugegraph.mapping.HugePersistentEntity;
import org.movee.spring.data.hugegraph.mapping.HugePersistentProperty;
import org.springframework.data.convert.EntityConverter;

import javax.annotation.Nullable;

public interface HugeConverter
        extends EntityConverter<HugePersistentEntity<?>, HugePersistentProperty, Object, Object> {

    /**
     * Returns the Id for an entity. It can return:
     * <ul>
     * <li>A singular value if for a simple {@link org.springframework.data.annotation.Id}
     *
     * @param bean must not be {@literal null}.
     * @param entity must not be {@literal null}.
     * @return the id value or {@literal null}, if the id is not set.
     */
    @Nullable
    Object getId(Object bean, HugePersistentEntity<?> entity);


    /**
     * Returns the underlying {@link HugeMappingContext} used by the converter.
     *
     * @return never {@literal null}
     */
    @Override
    HugeMappingContext getMappingContext();

    <T> Vertex convertEntityToVertex(T entity, Class<T> entityClass);

    <T> Edge convertEntityToEdge(T entity, Class<T> entityClass);
}
